package com.stellar.circle.controller.admin.sPostCategory;

import com.stellar.circle.controller.admin.sPostCategory.vo.SPostCategoryRequestPageVO;
import com.stellar.circle.controller.admin.sPostCategory.vo.SPostCategoryRequestVO;
import com.stellar.circle.controller.admin.sPostCategory.vo.SPostCategoryResponseVO;
import com.stellar.circle.domain.sPostCategory.SPostCategoryDomainService;

import com.stellar.web.core.bean.PageResult;
import com.stellar.web.core.bean.Result;
import com.stellar.web.core.validator.ValidatorRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 帖子分类表控制器
 *
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-17 19:12:02
 */
@RequestMapping("/api-admin/sPostCategory")
@RestController("adminSPostCategoryController")
@Slf4j
public class SPostCategoryController {

    @Resource
    private SPostCategoryDomainService sPostCategoryDomainService;

    /**
     * 分页查询帖子分类表
     */
    @ValidatorRole
    @PostMapping("/page")
    public Result<PageResult<SPostCategoryResponseVO>> page(@RequestBody SPostCategoryRequestPageVO requestPageVO) {
        return Result.success(sPostCategoryDomainService.page(requestPageVO));
    }

    /**
     * 新增帖子分类表
     */
    @ValidatorRole
    @PostMapping("/create")
    public Result<Boolean> create(@RequestBody SPostCategoryRequestVO requestVO) {
        return Result.success(sPostCategoryDomainService.insert(requestVO));
    }

    /**
     * 修改帖子分类表
     */
    @ValidatorRole
    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody SPostCategoryRequestVO requestVO) {
        return Result.success(sPostCategoryDomainService.update(requestVO));
    }

    /**
     * 删除帖子分类表
     */
    @ValidatorRole
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> delete(@PathVariable("id") Long id) {
        return Result.success(sPostCategoryDomainService.delete(id));
    }

    /**
     * 获取帖子分类表详情
     */
    @ValidatorRole
    @GetMapping("/get/{id}")
    public Result<SPostCategoryResponseVO> get(@PathVariable("id") Long id) {
        return Result.success(sPostCategoryDomainService.get(id));
    }
}
